#include "parseFile.h"
#include "manhattanCalc.h"
#include "parseNode.h"
#include "SmartPointer.h"
#include "euclidClass.h"
#include "gaschnigCalc.h"

heuristicCalc* makeHeuristicCalc(char* nb)
{
	if (nb[0] == '1')
		return (new manhattanCalc());
	else if (nb[0] == '2')
		return (new euclidClass());
	else if (nb[0] == '3')
		return (new gaschnigCalc());
	return NULL;
}

int	main(int ac, char **av)
{
	if( ac > 2 )
	{
		SmartPointer<heuristicCalc>			hCalc(makeHeuristicCalc(av[2]));
		parseFile			pFile(av[1]);
		SmartPointer<int>	puzzle(pFile.readAndMakeIS());

		if ( puzzle.getPointer() && hCalc.getPointer() )
		{
			SmartPointer<tNode>	inode( new tNode(hCalc, puzzle, SmartPointer<tNode>(), pFile.getLenTab(), 0));
			parseNode	pNode(std::string(inode.getPointer()->getKey()), pFile.makeFinalState(), inode);
			pNode.launchAStar();
			return 0;
		}
		return -1;
	}
	std::cout << "Usage : .\\taquin Pathfile Heuristic\nHeursitic:\n-1:Manatthan\n-2:Euclidienne\n-3:?" << std::endl;
	return -2;
}